<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
<title>车场</title>
<script type="text/javascript" src="/js/jquery.min.js"></script>
<script type="text/javascript">
	function carIn(plate){
		$.ajax({
			type : "get",
			url : "carin",
			data : {
				"plate" : plate
			},
			success : function(result) {
				var obj = result.resData.content;
				$('#info').html(JSON.stringify(result));
				var carmaster = obj.carmaster;
				var carInfo = obj.carInfo;
				var memberFlag = false;
				if('月租用户'==carmaster.cardType){
					memberFlag = true;
				}
				if(carInfo.iodataId>0){
					sendCarInToCenter(plate, memberFlag);
				}
			}
		});
	}
	
	function sendCarInToCenter(plate, memberFlag){
		$.ajax({
			type : "get",
			url : "${pageContext.request.contextPath }/data/serviceCenter/generateOrder",
			data : {
				"plateNumber": plate,
				"identification": '8360a98200dd9bd71343ef91d7374db6',
				"memberFlag": memberFlag
			},
			success : function(result) {
				$('#info').html(JSON.stringify(result));
			}
		});
	}
	
	
	function carOut(plate, paymentAmount, payMode){
		$.ajax({
			type : "get",
			url : "${pageContext.request.contextPath }/data/serviceCenter/closureOrder",
			data : {
				"plateNumber": plate,
				"identification": '8360a98200dd9bd71343ef91d7374db6',
				"paymentAmount": paymentAmount,
				"payMode": payMode
			},
			success : function(result) {
				$('#pay').html("支付出场" + JSON.stringify(result));
			}
		});
	}
</script>
</head>
<body><br>
	<button onclick="javascript: carIn('京A98765');">车入场</button>
	<div id="info"></div>
	<button onclick="javascript: carOut('京A98765', '31', 'wx');">车付款出场</button>
	<div id="pay"></div>
</body>
</html>
